package day10.CodeTransferTest;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class Test01 {
    public static void main(String[] args) throws Exception {
        String s = "abc中文喆镕";
        System.out.println(s); //abc中文喆镕

        f(s, null);
        f(s, "GBK");
        f(s, "GB2312");
        f(s, "UTF-8");
    }

    private static void f(String s, String encoding) throws Exception {
        //Unicode转其他编码
        byte[] a;
        if(encoding == null){
            a = s.getBytes();
        }else{
            a = s.getBytes(encoding);
        }
        System.out.println(encoding+'\t'+Arrays.toString(a));
    }
}
